<?php
class Comment_model extends CI_Model {

    var $owner_id = '';
    var $video_id = '';
    var $comment = '';
    
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    
    function get_comments($media_id)
    {
        $this->db->select('*');
        $this->db->where('video_id', $media_id);
        $this->db->join('profiles', 'comments.owner_id = profiles.user_id');
        $this->db->from('comments');   
        
        //$this->db->select('*');
        //$this->db->from('blogs');
        //$this->db->join('comments', 'comments.id = blogs.id');

        $query = $this->db->get();
        return $query->result('array');
    }
    
    function save_comment($video_id,$comment)
    {
        $data = array(
               'owner_id' => $this->session->userdata('user_id') ,
               'video_id' => $video_id,
               'comment' => $comment
            );
        
        $this->db->insert('comments', $data);
    }
}
?>